Skip to content

Conversation

@nlordell
Copy link

@nlordell nlordell commented May 21, 2025

Update 2025-05-22

After lengthy internal discussion, it was determined that the current behaviour is correct for Safe and CompatibilityFallbackHandler v1.3.0, while the proposed changes here are required for Safe v1.4.1+.

Additionally, note that the CompatibilityFallbackHandler v1.3.0 will not work with Safe v1.4.1 for contract owner signatures, because the dataHash == keccak256(data) invariant is not being respected.

What was wrong? 👾

It looks like the Safe transaction service is not correctly validating contract signatures for Safe messages. It uses the wrong preimage value for simulating the contract isValidSignature call which causes invalid signatures to be accepted, but valid signatures to be rejected.

As proof, you can "trick" the transaction service by uploading a signature for keccak256(keccak256(SafeMessage.message)). For example, the following signature was accepted by the safe transaction service despite not being valid:

https://app.safe.global/transactions/msg?safe=sep:0x2eB2E943a7877fcbC404351D7c8Ca5853B1a93D6&messageHash=0xe7ad065df60ded50e5c36a69333c2364f7592feeabfbba9ad0a17c74946d02ae

Here is a reverting simulation when trying to use the signature with isValidSignature:

https://www.tdly.co/shared/simulation/c58211dd-8e6a-40af-a935-5cb97da878a3

How was it fixed? 🎯

Using the correct pre-image for the Safe contract signatures. Depends on safe-global/safe-eth-py#1655.

Notes

I created this as a draft PR, but it is more like an issue 😅. I just thought it would be easier to point out where the exact problem is.

@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Uxio0 added a commit that referenced this pull request Jun 5, 2025
Uxio0 added a commit that referenced this pull request Jun 5, 2025
Uxio0 added a commit that referenced this pull request Jun 6, 2025
Uxio0 added a commit that referenced this pull request Jun 6, 2025
Uxio0 added a commit that referenced this pull request Jun 18, 2025
Uxio0 added a commit that referenced this pull request Jun 20, 2025
Uxio0 added a commit that referenced this pull request Jun 23, 2025
* Fix 1271 contract signatures
* Closes #2535 and #2526
* Add migration to delete contract signatures
* Add docs

---------

Co-authored-by: Uxio Fuentefria <[email protected]>
@Uxio0
Copy link
Member

Uxio0 commented Sep 3, 2025

Implemented in #2539

@Uxio0 Uxio0 closed this Sep 3, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants